<template>
	<view>
		<view style="margin-top: 10px;">
			<view id="nogonggao" v-if="gonggaoList.length<1">
			    还没有公告信息
			</view>
			<view v-if="gonggaoList.length>0">
				<view class="order-box" v-for="(item,i) in gonggaoList" :key="item.id">
					<view class="dtl-box" @click="goGonggaoDetail(item.id)">
					    <view class="dtl-head">
							<view class="beizhu">{{item.title}}</view>
					        <view class="money">{{item.createTime}}</view>
					    </view>
					    <view class="dtl-body">
							<view class="tuwen-box">
								<!-- <rich-text :nodes="item.message"></rich-text> -->
								<mp-html :content="switchImage(item.message)" />
							</view>
					    </view>
					</view>
				</view>
			</view>
		</view>
		<view class="tips-text">{{tips}}</view>
	</view>
</template>

<script>
	import mpHtml from '@/components/mp-html/mp-html'
	export default {
		data() {
			return {
				gonggaoList:[],//平台公告集合
				page:1,			//页数
				size:10,		//条数
				tips:"上拉加载更多数据",
			}
		},
		onReachBottom() {
			if(this.tips=='上拉加载更多数据'){
				this.page++;
				this.getJifenRecord();
			}
		},
		onLoad() {
			this.getJifenRecord();
		},
		methods: {
			//打倒积分创新创新
			getJifenRecord(n){
				this.$http.get('/pp_tongzhi/getTongzhi', {
					page:this.page,
					limit:this.size,
					gsid:0,
					userid:uni.getStorageSync('usersId')
				}).then(res => {
					if(res.data.data.length>0){
						this.gonggaoList=this.gonggaoList.concat(res.data.data);
						if(this.page==1 && res.data.data.length < this.size){
							this.tips = "";
						}
					}else{
						this.tips="没有更多数据";
					}
					if(this.gonggaoList.length < 1){
						this.tips = "";
					}
				})
			},
			//跳转公告详情
			goGonggaoDetail(id){
				uni.navigateTo({
					url:'pingtaiGonggaoDetail?id='+id
				})
			},
			// 转换图片地址
			switchImage(url){
				var reg = /\"\/image/g;
				url = url.replace(reg,'"'+this.host+'/image');
				return url.substr(0,120);
			}
		},
		components:{
			mpHtml
		}
	}
</script>

<style>
	.tixian-box{
		margin-top: 50px;
		background-color: white;
		padding: 10px;
	}
	.dtl-box{
		background-color: white;
		border-bottom: 1px solid #ccc;
		margin: 10px;
	}
	.dtl-head,.dtl-body{
		padding: 5px;
		display: flex;
		justify-content: space-between;
	}
	.dtl-head{
		font-size: 18px;
	}
	.time{
		color: #c7c7c7;
		font-size: 12px;
	}
	.beizhu,.money{
		flex: 1;
	}
	.beizhu{
		color: #3a8ee6;
	}
	.time img{
		width: 20px;
	}
	.beizhu,.time{
		/*文本溢出*/
		overflow:hidden;
		text-overflow:ellipsis;
		white-space:nowrap
	}
	.money{
		font-size: 10px;
		text-align: right;
	}
	#refreshContainer{
		padding-top: 4px;
	}
	#nogonggao{
		text-align: center;
		margin-top: 50px;
	}
	.tips-text{
		text-align: center;
	}
</style>
